package de.tudarmstadt.ukp.muip.fibqdojo.visitor;

import com.google.common.base.Optional;

import de.tudarmstadt.ukp.muip.fibqdojo.Sentence;
import de.tudarmstadt.ukp.muip.fibqdojo.SentenceToken;
import de.tudarmstadt.ukp.muip.fibqdojo.Token;
import de.tudarmstadt.ukp.muip.fibqdojo.interfaces.IFIBQToken;
import de.tudarmstadt.ukp.muip.fibqdojo.interfaces.IStructureVisitor;
import de.tudarmstadt.ukp.muip.fibqdojo.japanese.JapaneseToken;

public class CopyTokenVisitor implements IStructureVisitor {

    private Optional<IFIBQToken> copy = Optional.absent();

    public Optional<IFIBQToken> getCopy() {
        return copy;
    }

    @Override
    public void visit(JapaneseToken token) {
        String[] forms = token.getForms();
        String[] lemma = token.getLemma();
        String[] kana = token.getKana();
        String[] partOfSpeech = token.getPartOfSpeech();
        String[] kei = token.getKei();
        String[] meta = token.getDan();
        boolean simplify = token.isMarkedSimplified();
        JapaneseToken copiedToken = new JapaneseToken(forms, partOfSpeech, lemma, kana, kei, meta);
        copiedToken.setSimplify(simplify);
        IFIBQToken wrap = (IFIBQToken) copiedToken;
        copy = Optional.of(wrap);
    }

    @Override
    public void visit(Token token) {
        String form = token.getForm();
        String lemma = token.getLemma();
        String partOfSpeech = token.getPartOfSpeech();
        boolean simplify = token.isMarkedSimplified();

        Token copiedToken = new Token(form);
        copiedToken.setLemma(lemma);
        copiedToken.setPartOfSpeech(partOfSpeech);
        copiedToken.setSimplify(simplify);
        IFIBQToken wrap = (IFIBQToken) copiedToken;
        copy = Optional.of(wrap);
    }

    @Override
    public void visit(SentenceToken token) {
    }

    @Override
    public void visit(Sentence sentence) {
    }

}
